package kr.hyunist.androidcomplete01saeildamil.ch13;

import kr.hyunist.androidcomplete01saeildamil.*;
import android.app.*;
import android.os.*;
import android.view.*;
import android.view.View.OnClickListener;
import android.widget.*;
import android.widget.DatePicker.OnDateChangedListener;
import android.widget.TimePicker.OnTimeChangedListener;

public class DatePickerTimePickerEx extends Activity {
	DatePicker mDp;
	TimePicker mTp;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.datetimepickerex);

		mDp = (DatePicker) findViewById(R.id.datetimepickerexdp);
		mTp = (TimePicker) findViewById(R.id.datetimepickerextp);

		mDp.init(mDp.getYear(), mDp.getMonth(), mDp.getDayOfMonth(),
				new OnDateChangedListener() {

					@Override
					public void onDateChanged(DatePicker view, int year,
							int monthOfYear, int dayOfMonth) {

					}

				});

		mTp.setOnTimeChangedListener(new OnTimeChangedListener() {

			@Override
			public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {

			}

		});

		findViewById(R.id.datetimepickerexbtn).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						String result = String.format("%d년 %d월 %d일 %d시 %d분",
								mDp.getYear(), mDp.getMonth() + 1,
								mDp.getDayOfMonth(), mTp.getCurrentHour(),
								mTp.getCurrentMinute());
						Toast.makeText(DatePickerTimePickerEx.this, result, 0).show();
					}

				});
	}
}
